/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ace.game.entity.bullet;

import ace.game.GradientLine;
import ace.game.Sprite;
import ace.system.Utilities;
import ace.system.xml.XmlNode;

/**
 *
 * @author LegACy
 */
public class BulletData {
	protected BulletData() {
		//Initialize
		mBuff		= 0;
		mArea		= -1;
		mDamage		= 0;
		mDuration	= 200;
		mSprite		= null;
	}

	public BulletData(XmlNode xml) {
		//Default
		this();

		//Prepare variable
		XmlNode imageNode		= null;
		XmlNode gradientNode	= null;

		//For each child
		for (int i = 0; i < xml.getChildren().size(); i++) {
			//Get variable
			XmlNode Node	= (XmlNode)xml.getChildren().elementAt(i);
			String Tag		= Node.getNodeName();
			String Value	= ((XmlNode)Node.getChildren().elementAt(0)).getNodeValue();

			//Check based on tag name
			if (Tag.equals("area"))                 mArea			= Integer.parseInt(Value);
			else if (Tag.equals("damage"))          mDamage			= Integer.parseInt(Value);
			else if (Tag.equals("duration"))        mDuration		= Integer.parseInt(Value);
			else if (Tag.equals("sprite"))          imageNode		= Node;
			else if (Tag.equals("gradient"))        gradientNode	= Node;
			else if (Tag.equals("explosion"))       mExplosionColor	= Integer.parseInt(Value, 16);
			else if (Tag.equals("explosion-color"))	mExplosionColor	= Integer.parseInt(Value, 16);
		}
		//Create sprite
		if (imageNode != null) {
			mSprite = new Sprite(imageNode, Utilities.BULLET_FOLDER);
		} else if (gradientNode != null) {
			mGradient = new GradientLine(gradientNode);
		} else {
			System.out.println("something is wrong!");
		}
	}

	public int getArea()				{	return mArea;               }
	public int getDamage()				{	return mDamage;             }
	public Sprite getSprite()			{	return mSprite;             }
	public int getExplosionColor()      {	return mExplosionColor;		}
	public GradientLine getGradient()	{	return mGradient;           }
	public long getDuration()			{	return mDuration;           }

	//Data
	protected int	mBuff;
	protected int	mArea;
	protected int	mDamage;
	protected long	mDuration;
    protected int   mExplosionColor;

	// image
	protected Sprite mSprite;
	protected GradientLine mGradient;
}
